package net.fltx.assets.config;

import net.fltx.assets.filter.AccessLogFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

@Configuration
public class AccessLogFilterConfig {


    @Bean
    public FilterRegistrationBean securityFilterRegistration() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(accessLogFilterBean());
        registrationBean.addUrlPatterns("/*");
        registrationBean.setName("accessLogFilter");
        registrationBean.setOrder(2);
        return registrationBean;
    }

    @Bean
    public Filter accessLogFilterBean() {
        return new AccessLogFilter();
    }
}